package net.zypro.sample.service;

import java.util.ArrayList;
import java.util.List;

import net.zypro.sample.model.Account;
import net.zypro.sample.utils.MD5Util;

import org.springframework.stereotype.Service;

@Service
public class AccountService {
	private static List<Account> accounts=new ArrayList<Account>();
	
	static{
		accounts.add(new Account(MD5Util.MD5("user1@test.com"),"user1@test.com","zy","12345"));
		accounts.add(new Account(MD5Util.MD5("user2@test.com"),"user2@test.com","wrq","12345"));
		accounts.add(new Account(MD5Util.MD5("user3@test.com"),"user3@test.com","hzj","12345"));
	}
	
	public Account login(String username,String password)
	{
		for(Account a:accounts)
		{
			if(a.getUsername().equals(username)&&a.getPassword().equals(password))
			{
				return a;
			}
		}
		
		return null;
	}
	
	public void register(Account account)
	{
		
	}
}
